feat: Add argreader utility#171
Draft
jake-arkinstall wants to merge 7 commits into
Draft
Conversation
…(0 and 1 values accepted)
…the qmain/main shim, allowing utilities to depend on the interface as a shared library
…interfaces, not libselene itself
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Presently we have no examples of utilities that can be used with Selene.
This PR adds one - an argument reader, that can be used to provide runtime parameters into the user program.
When building using the ArgReaderPlugin, user code gains access to the following functions:
Note that the tag strings follow the same format as result() and panic() in that they start with a length byte, must be utf-8, and are not required to be null-terminated. As such, their maximum length is 255 characters. They do not require namespacing (e.g. "USER:INT:" in the result stream), but this may be added as long as the arguments are provided with the same namespacing. Error handling is handled internally and will result in descriptive panics.
The user then runs selene within a context manager:
which writes parameters to a temporary YAML file, then sets the environment variable
SELENE_ARGREADER_INPUT_FILEto point to this file. When the user program is running and a parameter is read for the first time, this yaml file is parsed with Serde and stored in memory. Arguments are extracted based on the current shot.The ability to export utility calls to the selene Trace is also added, and ArgReader utilises this to provide each parameter's type and value upon read. In general this trace export provides additional insight into the order that things happen within a run, and allows for utilities making custom calls to log their activity.